<?php
/*
 * @Author: 李明
 * @Date: 2022-01-17 13:52:51
 * @LastEditTime: 2022-01-17 15:28:30
 * @LastEditors: 李明
 * @Description: 
 * @FilePath: /CRM2.0-PHP/app/Http/Resources/MessageRecord.php
 * @山东壹零贰肆信息科技有限公司
 */

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\JsonResource;

class MessageRecord extends JsonResource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        $data = parent::toArray($request);
        switch ($this->status) { // 1待发送 2发送中 3发送成功 4发送失败
            case '1':
                $data['status_str']  = '待发送';
                break;
            case '2':
                $data['status_str']  = '发送中';
                break;
            case '3':
                $data['status_str']  = '发送成功';
                break;
            case '4':
                $data['status_str']  = '发送失败';
                break;
            default:
                $data['status_str']  = '状态未知';
                break;
        }
        return $data;
    }
}
